#include<bits/stdc++.h>
using namespace std;
const int p=998244353;
inline void chadd(int &x,int y){
  if((x+=y)>=p)x-=p;
}
int main(){
  freopen("after.in","r",stdin);
  freopen("after.out","w",stdout);
  ios::sync_with_stdio(false);
  int n; cin>>n;
  vector<int> a(n),f(n);
  for(auto &i:a)cin>>i,i--;
  for(int i=0;i<n;i++){
    int l=i,r=i;
    while(l&&a[l-1]<a[i])l--;
    while(r+1<n&&a[r+1]<a[i])r++;
    for(int j=l;j<=r;j++)
      chadd(f[j],j?f[j-1]:1);
  }
  cout<<f[n-1]<<endl;
  return 0;
}